package com.henu.acmrating.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.henu.acmrating.dao.UserOjMapper;
import com.henu.acmrating.pojo.CfRating;
import com.henu.acmrating.pojo.RankItem;
import com.henu.acmrating.pojo.UserOj;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserOjService {

    @Resource
    private UserOjMapper userOjMapper;


    public int deleteByPrimaryKey(Integer id) {
        return userOjMapper.deleteByPrimaryKey(id);
    }


    public int insert(UserOj record) {
        return userOjMapper.insert(record);
    }


    public int insertOrUpdate(UserOj record) {
        return userOjMapper.insertOrUpdate(record);
    }


    public int insertOrUpdateSelective(UserOj record) {
        return userOjMapper.insertOrUpdateSelective(record);
    }


    public int insertSelective(UserOj record) {
        return userOjMapper.insertSelective(record);
    }


    public UserOj selectByPrimaryKey(Integer id) {
        return userOjMapper.selectByPrimaryKey(id);
    }


    public int updateByPrimaryKeySelective(UserOj record) {
        return userOjMapper.updateByPrimaryKeySelective(record);
    }


    public int updateByPrimaryKey(UserOj record) {
        return userOjMapper.updateByPrimaryKey(record);
    }


    public int updateBatch(List<UserOj> list) {
        return userOjMapper.updateBatch(list);
    }


    public int batchInsert(List<UserOj> list) {
        return userOjMapper.batchInsert(list);
    }

    public List<UserOj> selectByAccount(String account) {
        return userOjMapper.selectByAccount(account);
    }


    public UserOj selectByAccountAndOjName(String account, String ojName) {
        return userOjMapper.selectByAccountAndOjName(account, ojName);
    }

    public UserOj selectByUserIdAndOjName(Integer userId, String ojName) {
        return userOjMapper.selectByUserIdAndOjName(userId, ojName);
    }



    public List<UserOj> selectByOjName(String ojName) {
        return userOjMapper.selectByOjName(ojName);
    }

    public List<String> selectAccountByOjName(String ojName) {
        return userOjMapper.selectAccountByOjName(ojName);
    }

    public List<UserOj> selectByUserId(Integer userId) {
        return userOjMapper.selectByUserId(userId);
    }

    public List<CfRating> selectByCf() {
        return userOjMapper.selectByCf();
    }


    public PageInfo<RankItem> showRankwithPage(int page, int pageSize, int role) {
        PageHelper.startPage(page, pageSize);
        return new PageInfo<>(userOjMapper.showRank(role));
    }
}

